package 界面.组件.按钮

import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import cn.mujiankeji.mbrowser.界面.图标.MyIconPack
import cn.mujiankeji.mbrowser.界面.图标.myiconpack.选中填充
import cn.mujiankeji.mbrowser.界面.图标.myiconpack.未选中圆


@Composable
fun 按钮_单选(
    name : String,
    selected : Boolean,
    modifier: Modifier = Modifier.fillMaxSize(),
    onClick : () -> Unit){

    Box(modifier){
        Row(Modifier.align(Alignment.Center)
            .height(28.dp)
            .clip(MaterialTheme.shapes.small)
            .clickable {
                onClick()
            }
            .then(if (selected) Modifier.border(1.dp,MaterialTheme.colorScheme.primary,MaterialTheme.shapes.small)
            else Modifier)
            .padding(horizontal = 15.dp),
            verticalAlignment = Alignment.CenterVertically)
        {


            if (!selected){
                Icon(MyIconPack.未选中圆,"",
                    Modifier.size(14.dp),
                    tint = MaterialTheme.colorScheme.outline)
            }
            else{
                Icon(MyIconPack.选中填充,"",
                    Modifier.size(14.dp),
                    tint = MaterialTheme.colorScheme.primary)
            }

            Spacer(Modifier.width(5.dp))

            Text(name, style = MaterialTheme.typography.bodyMedium,
                color = MaterialTheme.colorScheme.onSurface)


            Spacer(Modifier.width(3.dp)) // 平衡图标对齐
        }
    }




}